<?php
class PriceCheck extends Check {
    public function addCheck(Model &$model,Array $condition=array()) {
        if(self::isNullString($_POST['price_left'])) {
            $this->flag = false;
            $this->message[] = '左价格区间不能为空!';
        }
        if(self::isNullString($_POST['price_right'])) {
            $this->flag = false;
            $this->message[] = '右价格区间不能为空!';
        }
        if(!self::isNumber($_POST['price_left'])) {
            $this->flag = false;
            $this->message[] = '左价格区间必须为数字!';
        }
        if(!self::isNumber($_POST['price_right'])) {
            $this->flag = false;
            $this->message[] = '右价格区间必须为数字!';
        }
        if($_POST['price_left'] >= $_POST['price_right']) {
            $this->flag = false;
            $this->message[] = '左价格区间必须小于右价格区间!';
        }
        if($model->isOne($condition)) {
            $this->flag = false;
            $this->message[] = '该价格区间已经存在，请不必重新添加!';
        }
        return $this->flag;
    }

    public function updateCheck(Model &$model) {
    if(self::isNullString($_POST['price_left'])) {
            $this->flag = false;
            $this->message[] = '左价格区间不能为空!';
        }
        if(self::isNullString($_POST['price_right'])) {
            $this->flag = false;
            $this->message[] = '右价格区间不能为空!';
        }
        if(!self::isNumber($_POST['price_left'])) {
            $this->flag = false;
            $this->message[] = '左价格区间必须为数字!';
        }
        if(!self::isNumber($_POST['price_right'])) {
            $this->flag = false;
            $this->message[] = '右价格区间必须为数字!';
        }
        if($_POST['price_left'] >= $_POST['price_right']) {
            $this->flag = false;
            $this->message[] = '左价格区间必须小于右价格区间!';
        }
        return $this->flag;
    }
}


?>